package services

import (
	"go.uber.org/zap"
	"mon-go-web/internal/models"
	"mon-go-web/internal/repository"
	"mon-go-web/pkg/logger"
)

type ArticleService struct {
	articleRepository *repository.ArticleRepository
}

func NewArticleService() *ArticleService {
	return &ArticleService{articleRepository: repository.NewArticleRepository()}
}

func (as *ArticleService) Create(article *models.Article) int64 {
	logger.Logger.Info("Creating article", zap.Any("article", article))
	rows := as.articleRepository.Create(article)
	return rows
}

func (as *ArticleService) GetAll() []models.Article {
	all := as.articleRepository.GetAll()
	return all
}
